<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('智慧校园-排课打印')" />
</head>
<style>
    .input_line{
        border-bottom: 1px solid #000;
        border-top: 0px;
        border-left: 0px;
        border-right: 0px;
        outline: none;
    }
</style>
<body class="white-bg " >
<div class="navbar navbar-inverse navbar-fixed-top ">
    <div class="container-fluid">
        <button class="fa fa-print btn btn-primary btn-sm " onclick="print()">打印</button>
    </div>
</div>
<div class="wrapper wrapper-content animated fadeInRight ibox-content" id="print_content" style="margin-top: 18px;">
        <form class="form-horizontal m" id="course_schedule_print">
            <div class="form-group">
                <div class="col-sm-12 m-auto text-center">
                    <h3>[[${name}]]</h3>
                </div>
            </div>

            <div class="form-group" th:each="w0,iterStat : ${list}">
                <div class="col-sm-12 m-auto">
                    <h4 class="text-center" th:text="${w0.scheduleName + '---'+ w0.typeName }"></h4>
                    <div class="table-striped table-bordered">
                        <table th:id="'bootstrap-table'+${iterStat.index}"></table>
                    </div>
                </div>
            </div>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:src="@{/jasonday-printThis/printThis.js}"></script>
    <script th:inline="javascript">

        var list2 = [[${list}]];

        var options = {
            columns: [
                {
                    field: 'section',
                    title: '节次',
                    width:60
                },
                {
                    field: 'w1',
                    title: '星期一',
                    width:80,
                    formatter:function(value, row, index) {
                        return fmtV(row,value,"w1");
                    }
                },
                {
                    field: 'w2',
                    title: '星期二',
                    width:80,
                    formatter:function(value, row, index) {
                        return fmtV(row,value,"w2");
                    }
                },
                {
                    field: 'w3',
                    title: '星期三',
                    width:80,
                    formatter:function(value, row, index) {
                        return fmtV(row,value,"w3");
                    }
                },
                {
                    field: 'w4',
                    title: '星期四',
                    width:80,
                    formatter:function(value, row, index) {
                        return fmtV(row,value,"w4");
                    }
                },
                {
                    field: 'w5',
                    title: '星期五',
                    width:80,
                    formatter:function(value, row, index) {
                        return fmtV(row,value,"w5");
                    }
                },
                {
                    field: 'w6',
                    title: '星期六',
                    width:80,
                    formatter:function(value, row, index) {
                        return fmtV(row,value,"w6");
                    }
                },
                {
                    field: 'w7',
                    title: '星期日',
                    width:80,
                    formatter:function(value, row, index) {
                        return fmtV(row,value,"w7");
                    }
                }
            ],
            data:[]
        }

        $(()=>{
            for(let i=0;i<list2.length;i++){
                let id = "#bootstrap-table"+i;
                $(id).bootstrapTable(options);
                $(id).bootstrapTable('load',list2[i].list);
            }
        })

        function print(){
            $("#print_content").printThis();
        }

        function fmtV(row,value,key){
            var st = row[key+"_s"];
            if(st != undefined){
                if(st==-1){
                    return "<span class='badge badge-danger' disabled='true'>"+value+"</span>"
                }
                if(st ==1){
                    return "<span class='badge badge-success'>"+value+"</span>"
                }
            }
            return value;
        }

    </script>
</body>
</html>